package com.msb.简单树;


// 测试链接：https://leetcode.com/problems/same-tree
public class Code02_SameTree_Easy {

    public static class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;
    }

    // 注意为空不为空的判断, 防空指针即可
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null ^ q == null) {
            return false;
        }
        if (p == null) {
            return true;
        }
        return p.val == q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
    }
}
